<!--
 * @Author: ChunLai
 * @Date: 2022-04-18 16:24:34
 * @LastEditTime: 2025-09-10 17:33:38
 * @Description: 非组合式多选责任(责任转化为list形式传给接口)
 * @FilePath: \02.bldinsure\src\views\count\components\Liability3List.vue
-->
<template>
  <div class="liability-module w100">
    <div
      :class="['van-checkbox pd8_tb', duty.desc ? 'btm_line' : '']"
      v-for="(duty, index) in dutyList"
      :key="`${duty.value}${index}`"
    >
      <div class="van-checkbox__label w100">
        <div class="flex pb5">
          <span class="lh16 label-w">{{ duty.label }}</span>
          <FieldDescMode
            :label="duty.label"
            :desc="duty.desc"
            v-if="duty.desc"
          />
        </div>
        <p class="none_msg" v-if="duty.errTips">{{ duty.errTips }}</p>
        <RadioTwoSpan
          :list="duty.options"
          :duty="duty"
          :fid="index"
          @clickEvent="changeDutyRadio"
        />
      </div>
    </div>
  </div>
</template>

<script>
import FieldDescMode from "./FieldDescMode";
import RadioTwoSpan from "./RadioTwoSpan";
import { fmtWanYuan } from "@/methods/format.js";
export default {
  name: "Liability3List",
  props: {
    insuData: {
      type: Object,
      default: () => {},
    },
  },
  computed: {
    dutyList() {
      let res = [];
      if (this.insuData.duty3List) {
        res = this.insuData.duty3List;
      }
      return res;
    },
  },
  data() {
    return {};
  },
  components: { RadioTwoSpan, FieldDescMode },
  methods: {
    changeDutyRadio(index, duty, ele) {
      /*按钮不可点击 insuData*/
      if (duty.chooseLimit) {
        const dty3ChkObj = duty.chooseLimit;
        if (dty3ChkObj.minAmnt && this.insuData.amnt < dty3ChkObj.minAmnt) {
          if (ele.value !== "0") {
            return this.$toast(
              `基本保额${fmtWanYuan(dty3ChkObj.minAmnt)}元(含)以上可选`
            );
          }
        }
      }
      // if (duty.forbid) {
      //   duty.forbidTip && this.$toast(duty.forbidTip);
      //   return;
      // }
      // if (duty.mustChoose && ele.value == "0") {
      //   duty.forbidTip && this.$toast(duty.forbidTip);
      //   return;
      // }
      let dutys = JSON.parse(JSON.stringify(this.dutyList));
      dutys[index].value = ele.value;
      dutys[index].isChecked = ele.value !== "0";
      // console.log('2---', dutys)
      this.$store.dispatch("risks/setRisks", {
        varietyCode: this.insuData.varietyCode,
        type: "duty3List",
        val: dutys,
      });
      this.$forceUpdate();
    },
  },
};
</script>

<style lang="less" scoped>
.none_msg {
  font-size: 12px;
  color: #ff976a; //#b1b5b9;ff976a;
}

.van-checkbox__label {
  color: #1b1b1b;
  line-height: 14px;
}

.liability-module {
  /deep/.van-checkbox__icon--checked {
    .van-icon {
      border-color: #f54040;
      background-color: #f54040;
    }
  }
}
</style>
